using System.Collections.Generic;

namespace PKGames.Analytics
{
	public class AnalyticsManager : MonoSingleton<AnalyticsManager>
	{
		public const int TypeFaster = 1;

		public const int TypeFirebase = 2;

		private IAnalyticsLogger _fasterLogger;

		private IAnalyticsLogger _firebaseLogger;

		protected override void Awake()
		{
			base.Awake();
			Init();
		}

		public void Init()
		{
			_fasterLogger = AnalyticsLoggerFactory.CreateFasterLogger();
			_firebaseLogger = AnalyticsLoggerFactory.CreateFirebaseLogger();
		}

		public void LogEvent(string eventId, int typeMask, int eventRevision = 0)
		{
			if ((typeMask & 1) != 0)
			{
				_fasterLogger.LogEvent(eventId, eventRevision);
			}
		}

		public void LogEvent(string eventId, Dictionary<string, UnityEncodedPrimitiveData> parameters, int typeMask, int eventRevision = 0)
		{
			if ((typeMask & 1) != 0)
			{
				_fasterLogger.LogEvent(eventId, parameters, eventRevision);
			}
			if ((typeMask & 2) != 0)
			{
				_firebaseLogger.LogEvent(eventId, parameters, eventRevision);
			}
		}
	}
}
